<template>
    <div>
      <el-dialog
        title="添加通知"
        :visible.sync="noticeVisible"
        width="40%"
        :show-close="false"
        :close-on-click-modal="false">
        <el-form ref="noticeForm" :model="noticeForm" :rules="noticeForm_rules" label-width="110px">
          <!--<el-form-item label="标题" prop="n_title">-->
            <!--<el-input v-model="noticeForm.n_title" size="small" style="width: 80%"></el-input>-->
          <!--</el-form-item>-->
          <el-form-item label="内容" prop="n_content">
            <el-input v-model="noticeForm.n_content" size="small" style="width: 80%"></el-input>
          </el-form-item>
          <el-form-item label="开始时间" prop="n_start_time">
            <el-date-picker size="mini"
                            v-model="noticeForm.n_start_time"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            type="datetime"
                            placeholder="选择日期时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="结束时间" prop="n_end_time">
            <el-date-picker size="mini"
                            v-model="noticeForm.n_end_time"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            type="datetime"
                            placeholder="选择日期时间">
            </el-date-picker>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
      <el-button size="mini" @click="closeDialog">取 消</el-button>
      <el-button size="mini" type="primary" @click="addInfo">确 定</el-button>
    </span>
      </el-dialog>
    </div>
</template>
<script>
  import {addNotice,deleteNotices,updateNoticeById,findNoticeByPage,queryNoticeNowTime} from '@/api/system'
  export default{
      props:["isShowAdd"],
     data(){
         return {
             noticeVisible:this.isShowAdd,

             noticeForm:{
                n_title:"",
                n_content:"",
                n_start_time:"",
                n_end_time:""
             },

             noticeForm_rules:{
               n_content:[{ required: true, message: '不能为空', trigger: 'change' }],
               n_start_time:[{ required: true, message: '不能为空', trigger: 'change' }],
               n_end_time:[{ required: true, message: '不能为空', trigger: 'change' }],
             }
         }

     },
     methods:{
       closeDialog(){
          this.noticeVisible = false;
          this.$emit("closeDialog","add");
       },

       addInfo(){
         this.$refs["noticeForm"].validate((valid) => {
             if(valid){
               addNotice(this.noticeForm).then(res=>{
                   if(res.code == 200){
                       this.closeDialog();
                   }
               });
             }
         });
       }

     }
  }
</script>
